import {Component, OnInit} from '@angular/core';

@Component({
  selector: 'app-product',
  templateUrl: './product.component.html',
  styleUrls: ['./product.component.css']
})
export class ProductComponent implements OnInit {

  private products: Array<Product>;

  constructor() {
  }

  ngOnInit() {
    this.products = [
      new Product('商品1', 1, 1),
      new Product('商品2', 2, 2),
      new Product('商品3', 3, 3),
      new Product('商品4', 4, 4),
      new Product('商品5', 5, 5),
      new Product('商品6', 6, 6),
      new Product('商品7', 7, 7),
      new Product('商品18', 8, 8),
    ];
  }

}

export class Product {
  private _title: string;
  private _price: number;
  private _rate: number;

  constructor(title: string, price: number, rate: number) {
    this._title = title;
    this._price = price;
    this._rate = rate;
  }

  get title(): string {
    return this._title;
  }

  set title(value: string) {
    this._title = value;
  }

  get price(): number {
    return this._price;
  }

  set price(value: number) {
    this._price = value;
  }

  get rate(): number {
    return this._rate;
  }

  set rate(value: number) {
    this._rate = value;
  }
}
